﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterCustomer.master" AutoEventWireup="true" CodeBehind="RegisterCustomer.aspx.cs" Inherits="UdrinkWater_Project.RegisterCustomer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <script type="text/javascript">
    // <![CDATA[
         function OnNameValidation(s, e) {
             var name = e.value;
             if (name == null)
                 return;
             if (name.length < 6)
                 e.isValid = false;
         }
         function OnAgeValidation(s, e) {
             var age = e.value;
             if (age == null || age == "")
                 return;
             var digits = "0123456789";
             for (var i = 0; i < age.length; i++) {
                 if (digits.indexOf(age.charAt(i)) == -1) {
                     e.isValid = false;
                     break;
                 }
             }
             if (e.isValid && age.charAt(0) == '0') {
                 age = age.replace(/^0+/, "");
                 if (age.length == 0)
                     age = "0";
                 e.value = age;
             }
             if (age.length < 13)
                 e.isValid = false;
         }
         function OnSalary(s, e) {
             var age = e.value;
             if (age == null || age == "")
                 return;
             var digits = "0123456789";
             for (var i = 0; i < age.length; i++) {
                 if (digits.indexOf(age.charAt(i)) == -1) {
                     e.isValid = false;
                     break;
                 }
             }
             if (e.isValid && age.charAt(0) == '0') {
                 age = age.replace(/^0+/, "");
                 if (age.length == 0)
                     age = "0";
                 e.value = age;
             }
             if (age.length < 4)
                 e.isValid = false;
         }
         function OnArrivalDateValidation(s, e) {
             var selectedDate = s.date;
             if (selectedDate == null || selectedDate == false)
                 return;
             var currentDate = new Date();
             if (currentDate.getFullYear() != selectedDate.getFullYear() || currentDate.getMonth() != selectedDate.getMonth())
                 e.isValid = false;
         }
    // ]]>
    </script>
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Width="100%" 
         HeaderText="สมัครสมาชิก">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">
    <table style="width:100%;">
        <tr>
            <td style="width: 291px; text-align: right;">
                เลขที่บัตรประจำตัวประชาชน :</td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txtID" EnableClientSideAPI="True" runat="server" Width="170px">
                    <ValidationSettings ValidationGroup="RegisterUserValidationGroup" 
                        ErrorText="เลขบัตรประชาชน 13 หลัก" SetFocusOnError="True">
                        <RequiredField ErrorText="กรุณากรอกข้อมูล" IsRequired="true" />
                    </ValidationSettings>
                    <ClientSideEvents Validation="OnAgeValidation" />
                </dx:ASPxTextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                รหัสผ่าน :</td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txtPass" runat="server" Password="True" Width="170px">
                    <ValidationSettings ValidationGroup="RegisterUserValidationGroup"
                     ErrorText="ตัวเลข หรืออักขระต้องมากกว่า 6 ตัวอักษร" SetFocusOnError="True">
                        <RequiredField ErrorText="กรุณากรอกข้อมูล" IsRequired="true" />
                    </ValidationSettings>
                    <ClientSideEvents Validation="OnNameValidation" />
                </dx:ASPxTextBox>
                <asp:Label ID="Label2" runat="server" Font-Size="14px">(ตัวเลข หรือตัวอักขระ 6 ตัวขึ้นไป)</asp:Label>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                คำนำหน้า :</td>
            <td style="width: 238px">
                <dx:ASPxComboBox ID="cb_Prefix" runat="server" SelectedIndex="0">
                    <Items>
                        <dx:ListEditItem Selected="True" Text="นาย" Value="0" />
                        <dx:ListEditItem Text="นาง" Value="1" />
                        <dx:ListEditItem Text="นางสาว" Value="2" />
                    </Items>
                </dx:ASPxComboBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="height: 23px; width: 291px; text-align: right;">
                ชื่อ :</td>
            <td style="height: 23px; width: 238px">
                <dx:ASPxTextBox ID="txtFname" runat="server" Width="170px">
                    <ValidationSettings ValidationGroup="RegisterUserValidationGroup">
                        <RequiredField ErrorText="กรุณากรอกข้อมูล" IsRequired="true" />
                    </ValidationSettings>
                </dx:ASPxTextBox>
            </td>
            <td style="height: 23px">
                &nbsp;</td>
            <td style="height: 23px">
            </td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                นามสกุล :</td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txtLname" runat="server" Width="170px">
                    <ValidationSettings ValidationGroup="RegisterUserValidationGroup">
                        <RequiredField ErrorText="กรุณากรอกข้อมูล" IsRequired="true" />
                    </ValidationSettings>
                </dx:ASPxTextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                บ้านเลขที่ / หมู่ :
            </td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txtAdress" runat="server" Width="170px">
                    <ValidationSettings ValidationGroup="RegisterUserValidationGroup">
                        <RequiredField ErrorText="กรุณากรอกข้อมูล" IsRequired="true" />
                    </ValidationSettings>
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                จังหวัด :
            </td>
            <td style="width: 238px">
                <dx:ASPxComboBox ID="cb_Province" runat="server" AutoPostBack="True" 
                    DataSourceID="SqlDataSource_Province" TextField="PROVINCE_NAME" 
                    ValueField="PROVINCE_ID" ValueType="System.Int32" >
                </dx:ASPxComboBox>
                <asp:SqlDataSource ID="SqlDataSource_Province" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                    SelectCommand="SELECT * FROM [TB_Province] ORDER BY [PROVINCE_NAME]">
                </asp:SqlDataSource>
                </td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                อำเภอ :
            </td>
            <td style="width: 238px">
                <dx:ASPxComboBox ID="cb_Aumphur" runat="server" AutoPostBack="True" 
                    DataSourceID="SqlDataSource_Aumphur" TextField="AMPHUR_NAME" 
                    ValueField="AMPHUR_ID" ValueType="System.Int32" >
                </dx:ASPxComboBox>
                <asp:SqlDataSource ID="SqlDataSource_Aumphur" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                    SelectCommand="SELECT * FROM [TB_Aumphur] WHERE ([PROVINCE_ID] = @PROVINCE_ID) ORDER BY [AMPHUR_NAME]">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="cb_Province" Name="PROVINCE_ID" 
                            PropertyName="Value" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                ตำบล :
            </td>
            <td style="width: 238px">
                <dx:ASPxComboBox ID="cb_District" runat="server" 
                    DataSourceID="SqlDataSource_District" TextField="DISTRICT_NAME" 
                    ValueField="DISTRICT_ID" ValueType="System.Int32" >
                </dx:ASPxComboBox>
                <asp:SqlDataSource ID="SqlDataSource_District" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                    
                    SelectCommand="SELECT * FROM [TB_District] WHERE ([AMPHUR_ID] = @AMPHUR_ID) ORDER BY [DISTRICT_NAME]">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="cb_Aumphur" Name="AMPHUR_ID" 
                            PropertyName="Value" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                รหัสไปรษณีย์ :</td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txt_Zipcode" runat="server" Width="170px">
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                เบอร์โทรศัพท์ :</td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txtPhone" runat="server" Width="170px">
                </dx:ASPxTextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                อีเมลล์ : </td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txtmail" runat="server" Width="170px">
                </dx:ASPxTextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                โทรสาร :</td>
            <td style="width: 238px">
                <dx:ASPxTextBox ID="txtFax" runat="server" Width="170px">
                </dx:ASPxTextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                &nbsp;</td>
            <td style="width: 238px">
                <dx:ASPxButton ID="bt_Register" runat="server" ValidationGroup="RegisterUserValidationGroup"
                    Text="ลงทะเบียน" Theme="Youthful" Width="86px" onclick="bt_Register_Click">
                     <ClientSideEvents Click="function(s, e) {
	e.processOnServer = confirm('ยืนยันการสมัครสมาชิก');
}" />
                </dx:ASPxButton>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 291px; text-align: right;">
                &nbsp;</td>
            <td style="width: 238px">
                &nbsp;</td>
            <td>
            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
</asp:Content>
